#ifndef __DYNAMICARRAY_H_
#define __DYNAMICARRAY_H_

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define ElementType void*  //万能动态数组

struct DynamicArray;
typedef struct DynamicArray DArray;

DArray* InitDArray();
int GetSize(DArray *a);
ElementType *GetArray(DArray *a);
void InsertDArray(DArray *a,ElementType element);
void AppendDArray(DArray *a,ElementType element);
void PrintDArray(DArray *a,void (*print)(ElementType));
ElementType RemoveByIndex(DArray *a,int index);
ElementType RemoveDArray(DArray *a,ElementType value,bool(*compare)(ElementType,ElementType));

ElementType FindByElement(DArray *a,ElementType value,bool(*compare)(ElementType,ElementType));

void UpdateDArray(DArray *a, ElementType value, bool (*compare)(ElementType, ElementType) ,void (*update)(ElementType));

void ClearDArray(DArray *a,void(*clear)(ElementType));

void FindAllByElement(DArray *a, ElementType value, bool (*compare)(ElementType, ElementType), void (*print)(ElementType));

void FastSort(DArray *a,bool(*compare)(ElementType,ElementType));

ElementType BinarySearch(DArray *a,ElementType value,int(*compare)(ElementType,ElementType));



#endif